<template>
  <div>
    <h2>登录</h2>
    <div style="color: red;font-size: 12px">{{ errorInfo }}</div>
    用户名：
    <el-input v-model="loginObj.userName" placeholder="请输入用户名"></el-input>
    密码：
    <el-input type="password" v-model="loginObj.pwd" placeholder="请输入密码"></el-input>
    <el-button type="primary" @click="login()">登录</el-button>
  </div>
</template>

<script>
import axios from "axios"

export default {
  data() {
    return {
      errorInfo: "",
      loginObj: {},
    }
  },
  methods: {
    login() {
      axios.get("/project/user/login", {params: this.loginObj}).then(resp => {
        if (resp.data == "ok") {
          this.$router.push("/shopIndex");
        } else if (resp.data == "yes") {
          this.$router.push("/manageOrder");
        } else if (resp.data == "send") {
          this.$router.push("/sendOrder");
        } else {
          this.errorInfo = "登录失败";
        }
      })
    },
  }
}

</script>

<style scoped>

</style>